package tr.edu.yildiz.ce.dap.appagent.client;

import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class ClientMock {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		MulticastSocket socket = new MulticastSocket(4446);
		InetAddress group = InetAddress.getByName("230.0.0.1");
		socket.joinGroup(group);

		DatagramPacket packet;
		for (int i = 0; i < 5; i++) {
		    byte[] buf = new byte[5];
		    packet = new DatagramPacket(buf, buf.length);
		    socket.receive(packet);
		    
		    String received = new String(packet.getData());
		    System.out.println("Quote of the Moment: " + received);
		}
		socket.leaveGroup(group);
		socket.close();


	}

}
